//排行榜切换
var rankConf_top = {
	'tabs' : $("#top-tab .top-tab  a"),
	'contents' : $("#top-tab .wd-right-bang"),
	'tabShowClass' : 'on',
    'event' : 'click'
}
var tbChange_top = tabChange(rankConf_top);
tbChange_top.init();

var rankConf_tv = {
	'tabs' : $("#tvRec .right-smart-tab a"),
	'contents' : $("#tvRec .wwc"),
	'tabShowClass' : 'on',
    'event' : 'click'
}
var tbChange_tv = tabChange(rankConf_tv);
tbChange_tv.init();

var rankConf_movie = {
	'tabs' : $("#movieRec .right-smart-tab a"),
	'contents' : $("#movieRec .wwc"),
	'tabShowClass' : 'on',
    'event' : 'click'
}
var tbChange_movie = tabChange(rankConf_movie);
tbChange_movie.init();

var rankConf_variety = {
	'tabs' : $("#varietyRec .right-smart-tab a"),
	'contents' : $("#varietyRec .wwc"),
	'tabShowClass' : 'on',
    'event' : 'click'
}
var tbChange_variety= tabChange(rankConf_variety);
tbChange_variety.init();

var rankConf_cartoon = {
	'tabs' : $("#cartoonRec .right-smart-tab a"),
	'contents' : $("#cartoonRec .wwc"),
	'tabShowClass' : 'on',
    'event' : 'click'
}
var tbChange_cartoon= tabChange(rankConf_cartoon);
tbChange_cartoon.init();
//付费频道滚动
var rollConf = {
parent : $("#zhuanti .rolllist"),
toLeft : $("#zhuanti .roll-left"),
toRight : $("#zhuanti  .roll-right"),
oneWidth : 220,
pageNum : 4,
leftNum : 5.6,
allNum : $("#zhuanti .rolllist .home-album").length
}
width = rollConf.allNum*(200+20)+400+"px";
$("#zhuanti .rolllist").width(width);
imageRoll(rollConf);

function Lunbo(conf){
    var container = $(conf.container);
    var left = container.find(conf.left);
    var right = container.find(conf.right);
    var picsList = container.find(conf.picsList);
    var pagers = container.find(conf.pagers);
    var pagersList = pagers.find(conf.pagersList);

    var index = 0;
    var speed = conf.speed;
    var timer = null;
    var maxNum = pagersList.length;

    function show(){
        if (index >= maxNum){
            index = 0;
        }
        else if (index < 0){
            index = maxNum - 1;
        } 


        picsList.hide();
        pagersList.removeClass(conf.curpagerclass);

        $(picsList[index]).fadeIn('fast');
        $(pagersList[index]).addClass(conf.curpagerclass);
    }
    
    function start(){
        timer = setInterval(function(){
            index++;
            show();
        }, speed);
    }

    function stop(){
        if (timer){
            clearInterval(timer);
        }
    }
    
    function event(){
        left.click(function(){
            stop();
            index--;
            show();
            start();

            return false;
        });
        right.click(function(){
            stop();
            index++;
            show();
            start();

            return false;
        });
        
        pagers.on("mouseenter", conf.pagersList, function(){
            var elem = this;
            var i = getIndex(elem);
            stop();
            index = i;
            show();

            return false;
        });

        pagers.on("mouseleave", conf.pagersList, function(){
            start();

            return false;
        });

    }
    
    function getIndex(elem){
       for (var i=0; i<pagersList.length; i++){
           if (elem == pagersList[i]){
               return i;
           }
       }

       return false;
    }

    function init(){
        event();
        start();
    }

    return {init:init};
}
//热门视频的轮播
var indexShortVideoLunbo = Lunbo(
    {   
        container: "#lunbo",
        picsList:".Album1 a",
        left:".album-left",
        right:".album-right",
        pagers:".num",
        pagersList:"em",
        curpagerclass:"now",
        speed:5000
    }
);
indexShortVideoLunbo.init();
//顶部的大轮播图
var indexBigLunbo = Lunbo(
    {   
        container: ".index-ppt",
        picsList:".index-ppt-pic_data a",
        left:".left-btn",
        right:".right-btn",
        pagers:".add-ul",
        pagersList:"li a",
        curpagerclass:"play_current",
        speed:5000
    }
);
indexBigLunbo.init();

